<template>
<div class="user-page">
     <van-nav-bar
     left-arrow
      @click-left="$router.back()"
      fixed
      :border="false"
    ></van-nav-bar>
    <div class="user">
      <img :src="user.photo" alt="" />
      <div class="name">
          <p>{{user.name}}</p>
          <p>申请认证</p>
      </div>
    </div>
    <van-grid  :border="false" :column-num="3">
      <van-grid-item><span class="count">{{user.follow_count}}</span><span class="mic">动态</span></van-grid-item>
      <van-grid-item><span class="count">{{user.like_count}}</span><span class="mic">关注</span></van-grid-item>
      <van-grid-item><span class="count">{{user.fans_count}}</span><span class="mic">粉丝</span></van-grid-item>
   </van-grid>
    <van-cell-group inset class="mt20">
      <van-cell size="large" icon="fire-o" title="热门技术" is-link to="/count" />
      <van-cell size="large" icon="close" @click="logout" title="退出登录" is-link />
    </van-cell-group>

</div>
</template>

<script>
import { getUser } from '@/api/user'
import { Dialog } from 'vant'
import { delToken } from '@/utils/storage'
export default {
  name: 'user-page',
  components: {
    [Dialog.Component.name]: Dialog.Component
  },
  data () {
    return {
      user: {}
    }
  },
  async created () {
    const res = await getUser()
    console.log(res)
    this.user = res.data
  },
  methods: {
    async logout () {
      await Dialog.confirm({
        title: '是否退出登录',
        message: '这就走了？不爱我了吗？',
        confirmButtonColor: '#165DFF'
      })
      delToken()
      this.$router.push('/login')
    }
  }
}
</script>

<style lang="less" scoped>
.user-page {
  background-image: url("../assets/user.png");
  padding: 0 10px;
  height: 100vh;
  .mt20 {
    margin-top: 20px;
  }
  .user {
    display: flex;
    padding: 20px 20px;
    margin-top: 40px;
    align-items: center;
    img {
      width: 50px;
      height: 50px;
      border-radius: 50%;
      overflow: hidden;
    }

     .name {
        padding-left: 10px;
        p {
          &:first-child {
            font-size: 18px;
            font-weight: 500;
          }
          &:last-child {
            width: 62px;
            height: 24px;
            text-align: center;
            line-height: 24px;
            border-radius: 3px;
            background-color: #FBCF8D;
            margin-top: 10px;
            color: #6F3E00;
            font-size: 11px;
          }
        }
      }
    }

  }
.van-grid-item__content{
  .count{
    font-family: DINAlternate-Bold;
    font-size: 22px;
    color: #1D2129;
    text-align: center;
    line-height: 32px;
    font-weight: 600;
    margin-bottom: 8px;
  }
  .mic{
    font-family: PingFangSC-Regular;
    font-size: 12px;
    color: #86909C;
    text-align: center;
    line-height: 20px;
    font-weight: 400;
  }
}
</style>
